package io.gitee.chearnee.fw.socket.component.codec;

import io.gitee.chearnee.fw.socket.base.SocketConstant;
import io.gitee.chearnee.fw.socket.entity.MsgEntity;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToMessageDecoder;

import java.util.List;

public class NettyMessageDecode extends MessageToMessageDecoder<String> {
    @Override
    protected void decode(ChannelHandlerContext ctx, String msg, List<Object> out) throws Exception {
        MsgEntity msgEntity = SocketConstant.getObjectMapper().readValue(msg, MsgEntity.class);
        out.add(msgEntity);
    }
}
